<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style>
    	/* body{
    		
    	} */
    </style>
</head>
<body>
	 <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
         <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            选择任务单号
        </div> 
    </header> 
	<div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <!-- <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">计划日期</div>
                    <div class="aui-list-item-input" onclick="timePicker();">
                        <input type="text" placeholder="选择日期" class="aui-input" id="plandate">
                    </div>
                </div>
            </li>
        </ul> -->
        <ul class="aui-list aui-list-in" id="tbodyHtml">

        </ul>
    </div>
	<!-- <div id="equipTaskList" class="aui-content">
	    <ul class="aui-list-view" id ="tbodyHtml">
	      
	    </ul>
	</div> -->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
	apiready = function(){
		//var equipCode = api.pageParam.equipCode;
		var SRequipCode = api.pageParam.SRequipCode;
        var type = api.pageParam.type;
		getEquipTaskByEquipCode(SRequipCode,type);
	};
	
	function getEquipTaskByEquipCode(SRequipCode,type)
	{
		//alert("查询检修项");
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/getEquipTaskByEquipCode";
		var un = localStorage.getItem('un');
		
		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';
		params.returnAll = 'false';
		params.timeout = 60;
		
		var data = {
			values: { 
				un: un,
	            url: url,
	            SRequipCode: SRequipCode,
                type:type
	        }
		};
		
		// ajaxForData(params,data,false,function(ret, err){
		// 	var myobj = eval("("+ret.data+")");		
		// 	$("#equipTaskListUl").children().remove();
		// 	$("#equipTaskHCListUl").children().remove();
	    //     for (var i = 0; i < myobj.length; i++) {		       		
		// 		$("#equipTaskListUl").append("<li class='aui-list-view-cell'><a onclick='setEquipTask(\""+myobj[i].taskId+"\",\"" + myobj[i].taskCode + "\",\"" + myobj[i].equipId + "\",\"" + myobj[i].SRequipCode + "\",\"" + myobj[i].actualBeginDate + "\",\"" + myobj[i].actualEndDate + "\",\"" + myobj[i].taskResult + "\");' > "+ myobj[i].taskCode +"---"+ myobj[i].chkModeName +"</a></li>");
		// 	}
		// }); 
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 60,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    var list = myobj.list;
                    var html = "";
                    // $("#equipTaskListUl").children().remove();
		 	        // $("#equipTaskHCListUl").children().remove();
                    //遍历
//					alert(list)
					if(list != undefined && list != ""){
						for (var i = 0; i < list.length; i++) {
                        html += "<li class='aui-list-view-cell'><a onclick='setEquipTask(\""+list[i].taskId+"\",\"" + list[i].taskCode + "\",\"" + list[i].equipId + "\",\"" + list[i].SRequipCode + "\",\"" + list[i].actualBeginDate + "\",\"" + list[i].actualEndDate + "\",\"" + list[i].taskResult+ "\",\"" + list[i].taskState + "\");' > "+ list[i].taskCode +"---"+ list[i].chkModeName +"</a></li>";
                    }
					}

                    $api.html($api.byId("tbodyHtml"), html);

                } else if (myobj.code == '1') {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
	}
    

	function setEquipTask(id,code,equipId,SRequipCode,actualBeginDate,actualEndDate,taskResult)
	{
		api.closeWin();
		
		api.execScript({
			// name : 'about2',
			// frameName : 'about-con',
            name : 'uemChkTask',
			script : 'setEquipTask("'+id+'","'+code+'","'+equipId+'","'+SRequipCode+'","'+actualBeginDate+'","'+actualEndDate+'","'+taskResult+'")'
		});
	}
	//返回按钮
    function closeWin() {
        api.closeWin({});
    }

</script>
</html>